package com.lu.logAdvice;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component("sellLogAdvice")
@Aspect
public class SellLogAdvice {
    @Pointcut("execution(* *(..))")
    public void pt() {
    }

    @Before("pt()")
    public void befour() {
        System.out.println("befour");
    }

    @AfterReturning("pt()")
    public void afterReturning() {
        System.out.println("afterReturning");
    }

    @AfterThrowing("pt()")
    public void afterThrowing() {
        System.out.println("afterThrowing");
    }

    @After("pt()")
    public void after() {
        System.out.println("after");
    }
    /*@Around("pt()")
    public Object around(ProceedingJoinPoint pjp) {
        Object[] args = pjp.getArgs();
        int proced = 0;
        if ("vip".equals(args[1])) {
            System.out.println("您是尊贵的vip,尊享全场八折优惠,两倍积分");
            args[0] = (int) ((int) args[0] * 0.8);
        }else if ("svip".equals(args[1])){
            System.out.println("您是尊贵的svip,尊享全场7.5折优惠,两倍积分");
            args[0] = (int) ((int) args[0] * 0.75);
        }
        try {
            proced = (int) pjp.proceed(args);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        proced*=2;
        System.out.println("积分为"+proced);
        return proced;
        }*/



        /*int proceed = 0;
        System.out.println("原价为"+args[0]);
        args[0]=(int)((int)args[0]*0.5);
        try {
            proceed = (int) pjp.proceed(args);

        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        System.out.println("积分为"+proceed*2);
*/

}
